import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(home: AnimateContainerPage());
  }
}

class AnimateContainerPage extends StatefulWidget {
  @override
  _AnimateContainerPageState createState() => _AnimateContainerPageState();
}

class _AnimateContainerPageState extends State<AnimateContainerPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('动画示例')),
      body: SizedBox.expand(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            AnimatedContainer(
              width: 200,
              height: 400,
              padding: EdgeInsets.all(44),
              // color: Colors.blue,
              decoration: BoxDecoration(
                // color: Colors.blue,
                gradient: LinearGradient(colors: [Colors.red, Colors.yellow]),
                borderRadius: BorderRadius.all(Radius.circular(40)),
                border: Border.all(color: Colors.red, width: 30),
                boxShadow: [
                  BoxShadow(
                    color: Colors.black,
                    offset: Offset(dx, dy),
                    blurRadius: 10,
                  ),
                ],
              ),
              duration: Duration(seconds: 1),
              child: Container(color: Colors.transparent),
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          setState(() {
            dx += 10;
            dy += 10;
          });
        },
        child: Icon(Icons.change_circle),
      ),
    );
  }

  double dx = 10;
  double dy = 10;
}
